<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>前后端调用</title>
	</head>
	<body>
		<h1>前后端调用</h1>
		<script src="../js/axios.js"></script>
		
		<script>
		// GET方式一
		let url1="http://localhost:8090/axios/getUserById?id=1"
			axios.get(url1).then(Promise => {
				console.log(Promise.data)
			})
		// GET方式二
		// let sex="女"
		// let age=18
		// let url2=`http://localhost:8090/axios/user/${sex}/${age}`
		// axios.get(url2).then(Promise =>{
		// 	console.log(Promise.data)
		// })
		// let user= {
		// 		name:"王昭君",
		// 		sex:'女',
		// 		age:19
		// 	}
		// let url3="http://localhost:8090/axios/getUser"
		// axios.get(url3,{params : user}).then(Promise =>{
		// 	console.log(Promise.data)
		// 	})
			let url4="http://localhost:8090/axios/getUserById?id=2"
			axios.get(url4).then(Promise=>{
				console.log(Promise.data)
			})
			let name='貂蝉'
			let sex='女'
			let url5=`http://localhost:8090/axios/user/${name}/${sex}`
			axios.get(url5).then(Promise=>{
				console.log(Promise.data)
			})
			let user={
				name:"王昭君",
				sex:'女',
				age:19,
				
			}
			let url6="http://localhost:8090/axios/getuser"
			axios.get(url6,{params:user}).then(Promise=>{
				console.log(Promise.data)
			})
		</script>
		
	</body>
</html>
